﻿using System;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RaytracerLib;
using RaytracerLib.MathLib;
using TomanuExtensions;

namespace RaytracerTest
{
    [TestClass]
    public class ColorFloatTest : TestBase
    {
        [TestMethod]
        public void ColorFloat_Test()
        {
            ColorFloat_Constructor1();
            ColorFloat_Constructor2();
            ColorFloat_Constructor3();
            ColorFloat_Constructor4();
            ColorFloat_Constructor5();
            ColorFloat_Constructor6();
            ColorFloat_Overshoot();
            ColorFloat_Equals_Objects();
            ColorFloat_Equals_ColorFloat();
            ColorFloat_op_Subtraction();
            ColorFloat_op_Multiply_Single();
            ColorFloat_op_Multiply_ColorFloat();
            ColorFloat_op_Inequality();
            ColorFloat_op_Equality();
            ColorFloat_op_Division_ColorFloat();
            ColorFloat_op_Division_Single();
            ColorFloat_op_Addition();
            ColorFloat_op_UnaryMinus();
            ColorFloat_op_Cmp();
            ColorFloat_SystemColor();
            ColorFloat_Neg();
            ColorFloat_Avg();
            ColorFloat_Black();
            ColorFloat_AboveZero();
            ColorFloat_IsAlmostRelativeEquals();
        }

        private void ColorFloat_op_Cmp()
        {
            Assert.IsFalse(new ColorFloat(0, 0, 0) > new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(1, 0, 0) > new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 1, 0) > new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 1) > new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(-1, 0, 0) > new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, -1, 0) > new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, -1) > new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) > new ColorFloat(1, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) > new ColorFloat(0, 1, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) > new ColorFloat(0, 0, 1));
            Assert.IsFalse(new ColorFloat(0, 0, 0) > new ColorFloat(-1, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) > new ColorFloat(0, -1, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) > new ColorFloat(0, 0, -1));

            Assert.IsFalse(new ColorFloat(1, 1, 0) > new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(1, 0, 1) > new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 1, 1) > new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(1, 1, 1) > new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(-1, -1, -1) > new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) > new ColorFloat(1, 1, 1));
            Assert.IsTrue(new ColorFloat(0, 0, 0) > new ColorFloat(-1, -1, -1));

            Assert.IsTrue(new ColorFloat(0, 0, 0) >= new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(1, 0, 0) >= new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(0, 1, 0) >= new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(0, 0, 1) >= new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(-1, 0, 0) >= new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, -1, 0) >= new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, -1) >= new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) >= new ColorFloat(1, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) >= new ColorFloat(0, 1, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) >= new ColorFloat(0, 0, 1));
            Assert.IsTrue(new ColorFloat(0, 0, 0) >= new ColorFloat(-1, 0, 0));
            Assert.IsTrue(new ColorFloat(0, 0, 0) >= new ColorFloat(0, -1, 0));
            Assert.IsTrue(new ColorFloat(0, 0, 0) >= new ColorFloat(0, 0, -1));

            Assert.IsTrue(new ColorFloat(1, 1, 0) >= new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(1, 0, 1) >= new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(0, 1, 1) >= new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(1, 1, 1) >= new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(-1, -1, -1) >= new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) >= new ColorFloat(1, 1, 1));
            Assert.IsTrue(new ColorFloat(0, 0, 0) >= new ColorFloat(-1, -1, -1));

            Assert.IsFalse(new ColorFloat(0, 0, 0) < new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(1, 0, 0) < new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 1, 0) < new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 1) < new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(-1, 0, 0) < new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, -1, 0) < new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, -1) < new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) < new ColorFloat(1, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) < new ColorFloat(0, 1, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) < new ColorFloat(0, 0, 1));
            Assert.IsFalse(new ColorFloat(0, 0, 0) < new ColorFloat(-1, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) < new ColorFloat(0, -1, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) < new ColorFloat(0, 0, -1));

            Assert.IsFalse(new ColorFloat(1, 1, 0) < new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(1, 0, 1) < new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 1, 1) < new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(1, 1, 1) < new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(-1, -1, -1) < new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(0, 0, 0) < new ColorFloat(1, 1, 1));
            Assert.IsFalse(new ColorFloat(0, 0, 0) < new ColorFloat(-1, -1, -1));

            Assert.IsTrue(new ColorFloat(0, 0, 0) <= new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(1, 0, 0) <= new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 1, 0) <= new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 1) <= new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(-1, 0, 0) <= new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(0, -1, 0) <= new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(0, 0, -1) <= new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(0, 0, 0) <= new ColorFloat(1, 0, 0));
            Assert.IsTrue(new ColorFloat(0, 0, 0) <= new ColorFloat(0, 1, 0));
            Assert.IsTrue(new ColorFloat(0, 0, 0) <= new ColorFloat(0, 0, 1));
            Assert.IsFalse(new ColorFloat(0, 0, 0) <= new ColorFloat(-1, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) <= new ColorFloat(0, -1, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) <= new ColorFloat(0, 0, -1));

            Assert.IsFalse(new ColorFloat(1, 1, 0) <= new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(1, 0, 1) <= new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 1, 1) <= new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(1, 1, 1) <= new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(-1, -1, -1) <= new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(0, 0, 0) <= new ColorFloat(1, 1, 1));
            Assert.IsFalse(new ColorFloat(0, 0, 0) <= new ColorFloat(-1, -1, -1));
        }

        private void ColorFloat_IsAlmostRelativeEquals()
        {
            Assert.IsTrue(new ColorFloat(0, 0, 0).IsAlmostRelativeEquals(new ColorFloat(0, 0, 0)));

            Assert.IsTrue(new ColorFloat(Constants.COLOR_PRECISION / 2, 0, 0).IsAlmostRelativeEquals(
                new ColorFloat(0, 0, 0)));
            Assert.IsTrue(new ColorFloat(0, Constants.COLOR_PRECISION / 2, 0).IsAlmostRelativeEquals(
                new ColorFloat(0, 0, 0)));
            Assert.IsTrue(new ColorFloat(0, 0, Constants.COLOR_PRECISION / 2).IsAlmostRelativeEquals(
                new ColorFloat(0, 0, 0)));

            Assert.IsFalse(new ColorFloat(Constants.COLOR_PRECISION * 2, 0, 0).IsAlmostRelativeEquals(
                new ColorFloat(0, 0, 0)));
            Assert.IsFalse(new ColorFloat(0, Constants.COLOR_PRECISION * 2, 0).IsAlmostRelativeEquals(
                new ColorFloat(0, 0, 0)));
            Assert.IsFalse(new ColorFloat(0, 0, Constants.COLOR_PRECISION * 2).IsAlmostRelativeEquals(
                new ColorFloat(0, 0, 0)));

            Assert.IsTrue(new ColorFloat(1e8 + 1e8 * Constants.COLOR_PRECISION / 2, 0, 0).IsAlmostRelativeEquals(
               new ColorFloat(1e8, 0, 0)));
            Assert.IsTrue(new ColorFloat(0, 1e8 + 1e8 * Constants.COLOR_PRECISION / 2, 0).IsAlmostRelativeEquals(
                new ColorFloat(0, 1e8, 0)));
            Assert.IsTrue(new ColorFloat(0, 0, 1e8 + 1e8 * Constants.COLOR_PRECISION / 2).IsAlmostRelativeEquals(
                new ColorFloat(0, 0, 1e8)));

            Assert.IsFalse(new ColorFloat(1e8 + 1e8 * Constants.COLOR_PRECISION * 2, 0, 0).IsAlmostRelativeEquals(
                new ColorFloat(1e8, 0, 0)));
            Assert.IsFalse(new ColorFloat(0, 1e8 + 1e8 * Constants.COLOR_PRECISION * 2, 0).IsAlmostRelativeEquals(
                new ColorFloat(0, 1e8, 0)));
            Assert.IsFalse(new ColorFloat(0, 0, 1e8 + 1e8 * Constants.COLOR_PRECISION * 2).IsAlmostRelativeEquals(
                new ColorFloat(0, 0, 1e8)));
        }

        private void ColorFloat_AboveZero()
        {
            Assert.IsTrue(new ColorFloat(0, 0, 0).AboveZero == new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(0.1, 0, 0).AboveZero == new ColorFloat(0.1, 0, 0));
            Assert.IsTrue(new ColorFloat(0, 0.1, 0).AboveZero == new ColorFloat(0, 0.1, 0));
            Assert.IsTrue(new ColorFloat(0, 0, 0.1).AboveZero == new ColorFloat(0, 0, 0.1));

            Assert.IsTrue(new ColorFloat(-0.1, 0, 0).AboveZero == new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(0, -0.1, 0).AboveZero == new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(0, 0, -0.1).AboveZero == new ColorFloat(0, 0, 0));

            Assert.IsTrue(new ColorFloat(-0.1, 0.1, 0.2).AboveZero == new ColorFloat(0, 0.1, 0.2));
            Assert.IsTrue(new ColorFloat(0.1, -0.1, 0.2).AboveZero == new ColorFloat(0.1, 0, 0.2));
            Assert.IsTrue(new ColorFloat(0.1, 0.2, -0.1).AboveZero == new ColorFloat(0.1, 0.2, 0));

            Assert.IsTrue(new ColorFloat(-0.1, 0.1, 1.2).AboveZero == new ColorFloat(0, 0.1, 1.2));
            Assert.IsTrue(new ColorFloat(1.1, -0.1, 0.2).AboveZero == new ColorFloat(1.1, 0, 0.2));
            Assert.IsTrue(new ColorFloat(0.1, 1.2, -0.1).AboveZero == new ColorFloat(0.1, 1.2, 0));

            Assert.IsTrue(new ColorFloat(-1.1, 0.1, 1.2).AboveZero == new ColorFloat(0, 0.1, 1.2));
            Assert.IsTrue(new ColorFloat(1.1, -2.1, 0.2).AboveZero == new ColorFloat(1.1, 0, 0.2));
            Assert.IsTrue(new ColorFloat(0.1, 1.2, -3.1).AboveZero == new ColorFloat(0.1, 1.2, 0));         
        }

        public void ColorFloat_Overshoot()
        {
            ColorFloat c1 = new ColorFloat(0, 1, -1.2f);
            ColorFloat c2 = new ColorFloat(0, 1, 1.2f);

            Assert.AreEqual(c1.SystemColor, Color.FromArgb(0, 255, 0));
            Assert.AreEqual(c2.SystemColor, Color.FromArgb(0, 255, 255));
        }

        public void ColorFloat_Equals_Objects()
        {
            Object obj1 = new ColorFloat(1, 1, 1);
            Object obj2 = new ColorFloat(1, 1, 0.5f);
            Object obj3 = new ColorFloat(1, 0.5f, 1);
            Object obj4 = new ColorFloat(0.5f, 1, 1);
            Object obj5 = new ColorFloat(1, 1, 1);

            Object obj6 = null;

            Object obj7 = new ColorFloat(0, 0, 0);
            Object obj8 = new ColorFloat(0, 0, 0);

            Object obj9 = new ColorFloat(2, 2, 2);
            Object obj10 = new ColorFloat(2, 2, 2);

            Object obj11 = new ColorFloat(-2, -2, -2);
            Object obj12 = new ColorFloat(-2, -2, -2);

            Assert.IsTrue(obj1.Equals(obj1));
            Assert.IsTrue(obj1.Equals(obj5));

            Assert.IsFalse(obj1.Equals(obj2));
            Assert.IsFalse(obj1.Equals(obj3));
            Assert.IsFalse(obj1.Equals(obj4));

            Assert.IsFalse(obj1.Equals(obj6));

            Assert.IsTrue(obj7.Equals(obj8));
            Assert.IsTrue(obj9.Equals(obj10));
            Assert.IsTrue(obj11.Equals(obj12));

            Assert.IsFalse(obj1.Equals((Object)5));
            Assert.IsFalse(obj1.Equals(DateTime.Now));
        }

        public void ColorFloat_Equals_ColorFloat()
        {
            ColorFloat obj1 = new ColorFloat(1, 1, 1);
            ColorFloat obj2 = new ColorFloat(1, 1, 0.5f);
            ColorFloat obj3 = new ColorFloat(1, 0.5f, 1);
            ColorFloat obj4 = new ColorFloat(0.5f, 1, 1);
            ColorFloat obj5 = new ColorFloat(1, 1, 1);

            Object obj7 = new ColorFloat(0, 0, 0);
            Object obj8 = new ColorFloat(0, 0, 0);

            Object obj9 = new ColorFloat(2, 2, 2);
            Object obj10 = new ColorFloat(2, 2, 2);

            Object obj11 = new ColorFloat(-2, -2, -2);
            Object obj12 = new ColorFloat(-2, -2, -2);

            Assert.IsTrue(obj1.Equals(obj1));
            Assert.IsTrue(obj1.Equals(obj5));
            Assert.IsFalse(obj1.Equals(obj2));
            Assert.IsFalse(obj1.Equals(obj3));
            Assert.IsFalse(obj1.Equals(obj4));

            Assert.IsTrue(obj7.Equals(obj8));
            Assert.IsTrue(obj9.Equals(obj10));
            Assert.IsTrue(obj11.Equals(obj12));
        }

        private Color ConvertColor(Color c)
        {
            return Color.FromArgb(c.R, c.G, c.B);
        }

        public void ColorFloat_SystemColor()
        {
            Assert.IsTrue(new ColorFloat(Color.Blue).SystemColor ==
                ConvertColor(Color.Blue));
            Assert.IsTrue(new ColorFloat(Color.Red).SystemColor ==
                ConvertColor(Color.Red));
            Assert.IsTrue(new ColorFloat(Color.Green).SystemColor ==
                ConvertColor(Color.Green));
            Assert.IsTrue(new ColorFloat(Color.LightGray).SystemColor ==
                ConvertColor(Color.LightGray));
            Assert.IsTrue(new ColorFloat(Color.Black).SystemColor ==
                ConvertColor(Color.Black));
            Assert.IsTrue(new ColorFloat(Color.White).SystemColor ==
                ConvertColor(Color.White));
        }

        public void ColorFloat_Neg()
        {
            Assert.IsTrue(new ColorFloat(0, 0, 0).Neg.IsAlmostRelativeEquals(
                new ColorFloat(1, 1, 1)));
            Assert.IsTrue(new ColorFloat(1, 1, 1).Neg.IsAlmostRelativeEquals(
                new ColorFloat(0, 0, 0)));
            Assert.IsTrue(new ColorFloat(2, 2, 2).Neg.IsAlmostRelativeEquals(
                new ColorFloat(-1, -1, -1)));
            Assert.IsTrue(new ColorFloat(-1, -1, -1).Neg.IsAlmostRelativeEquals(
                new ColorFloat(2, 2, 2)));
            Assert.IsTrue(new ColorFloat(0.3f, 0, 0).Neg.IsAlmostRelativeEquals(
                new ColorFloat(0.7f, 1, 1)));
            Assert.IsTrue(new ColorFloat(0, 0.3f, 0).Neg.IsAlmostRelativeEquals(
                new ColorFloat(1, 0.7f, 1)));
            Assert.IsTrue(new ColorFloat(0, 0, 0.3f).Neg.IsAlmostRelativeEquals(
                new ColorFloat(1, 1, 0.7f)));
        }

        public void ColorFloat_Avg()
        {
            Assert.IsTrue(new ColorFloat(0, 0, 0).Avg.IsAlmostRelativeEquals(0.0f));
            Assert.IsTrue(new ColorFloat(0.1f, 0.1f, 0.1f).Avg.IsAlmostRelativeEquals(0.1f));
            Assert.IsTrue(new ColorFloat(1, 1, 1).Avg.IsAlmostRelativeEquals(1.0f));
            Assert.IsTrue(new ColorFloat(2, 2, 2).Avg.IsAlmostRelativeEquals(2.0f));
            Assert.IsTrue(new ColorFloat(-1, -1, -1).Avg.IsAlmostRelativeEquals(-1.0f));
            Assert.IsTrue(new ColorFloat(0.3f, 0, 0).Avg.IsAlmostRelativeEquals(0.1f, Constants.COLOR_PRECISION));
            Assert.IsTrue(new ColorFloat(0, 0.3f, 0).Avg.IsAlmostRelativeEquals(0.1f, Constants.COLOR_PRECISION));
            Assert.IsTrue(new ColorFloat(0, 0, 0.3f).Avg.IsAlmostRelativeEquals(0.1f, Constants.COLOR_PRECISION));
        }

        public void ColorFloat_op_Subtraction()
        {
            Assert.IsTrue((new ColorFloat(1, 1, 1) - new ColorFloat(0, 0, 0)) == new ColorFloat(1, 1, 1));
            Assert.IsTrue((new ColorFloat(-1, -1, -1) - new ColorFloat(0, 0, 0)) == new ColorFloat(-1, -1, -1));
            Assert.IsTrue((new ColorFloat(2, 2, 2) - new ColorFloat(0, 0, 0)) == new ColorFloat(2, 2, 2));
            Assert.IsTrue((new ColorFloat(0, 0, 0) - new ColorFloat(0, 0, 0)) == new ColorFloat(0, 0, 0));

            Assert.IsTrue((new ColorFloat(1, 1, 1) - new ColorFloat(1, 1, 1)) == new ColorFloat(0, 0, 0));
            Assert.IsTrue((new ColorFloat(-1, -1, -1) - new ColorFloat(1, 1, 1)) == new ColorFloat(-2, -2, -2));
            Assert.IsTrue((new ColorFloat(2, 2, 2) - new ColorFloat(1, 1, 1)) == new ColorFloat(1, 1, 1));
            Assert.IsTrue((new ColorFloat(0, 0, 0) - new ColorFloat(1, 1, 1)) == new ColorFloat(-1, -1, -1));

            Assert.IsTrue((new ColorFloat(1, 1, 1) - new ColorFloat(-1, -1, -1)) == new ColorFloat(2, 2, 2));
            Assert.IsTrue((new ColorFloat(-1, -1, -1) - new ColorFloat(-1, -1, -1)) == new ColorFloat(0, 0, 0));
            Assert.IsTrue((new ColorFloat(2, 2, 2) - new ColorFloat(-1, -1, -1)) == new ColorFloat(3, 3, 3));
            Assert.IsTrue((new ColorFloat(0, 0, 0) - new ColorFloat(-1, -1, -1)) == new ColorFloat(1, 1, 1));

            Assert.IsTrue((new ColorFloat(1.6f, 1.4f, 1.2f) - new ColorFloat(1, 0, 0)).IsAlmostRelativeEquals(new ColorFloat(0.6f, 1.4f, 1.2f)));
            Assert.IsTrue((new ColorFloat(1.6f, 1.4f, 1.2f) - new ColorFloat(0, 1, 0)).IsAlmostRelativeEquals(new ColorFloat(1.6f, 0.4f, 1.2f)));
            Assert.IsTrue((new ColorFloat(1.6f, 1.4f, 1.2f) - new ColorFloat(0, 0, 1)).IsAlmostRelativeEquals(new ColorFloat(1.6f, 1.4f, 0.2f)));
        }

        public void ColorFloat_op_Multiply_Single()
        {
            {
                Assert.IsTrue((new ColorFloat(1, 1, 1) * 1) ==
                    new ColorFloat(1, 1, 1));
                Assert.IsTrue((new ColorFloat(-1, -1, -1) * 1) ==
                    new ColorFloat(-1, -1, -1));
                Assert.IsTrue((new ColorFloat(2, 2, 2) * 1) ==
                    new ColorFloat(2, 2, 2));
                Assert.IsTrue((new ColorFloat(0, 0, 0) * 1) ==
                    new ColorFloat(0, 0, 0));

                Assert.IsTrue((new ColorFloat(1, 1, 1) * 0) ==
                    new ColorFloat(0, 0, 0));
                Assert.IsTrue((new ColorFloat(-1, -1, -1) * 0) ==
                    new ColorFloat(0, 0, 0));
                Assert.IsTrue((new ColorFloat(2, 2, 2) * 0) ==
                    new ColorFloat(0, 0, 0));
                Assert.IsTrue((new ColorFloat(0, 0, 0) * 0) ==
                    new ColorFloat(0, 0, 0));

                Assert.IsTrue((new ColorFloat(1, 1, 1) * -1) ==
                    new ColorFloat(-1, -1, -1));
                Assert.IsTrue((new ColorFloat(-1, -1, -1) * -1) ==
                    new ColorFloat(1, 1, 1));
                Assert.IsTrue((new ColorFloat(2, 2, 2) * -1) ==
                    new ColorFloat(-2, -2, -2));
                Assert.IsTrue((new ColorFloat(0, 0, 0) * -1) ==
                    new ColorFloat(0, 0, 0));

                Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) * 0.5f) ==
                    new ColorFloat(0.3f, 0.2f, 0.1f));
                Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) * -0.5f) ==
                    new ColorFloat(-0.3f, -0.2f, -0.1f));
            }

            {
                Assert.IsTrue((1 * new ColorFloat(1, 1, 1)) ==
                    new ColorFloat(1, 1, 1));
                Assert.IsTrue((1 * new ColorFloat(-1, -1, -1)) ==
                    new ColorFloat(-1, -1, -1));
                Assert.IsTrue((1 * new ColorFloat(2, 2, 2)) ==
                    new ColorFloat(2, 2, 2));
                Assert.IsTrue((1 * new ColorFloat(0, 0, 0)) ==
                    new ColorFloat(0, 0, 0));

                Assert.IsTrue((0 * new ColorFloat(1, 1, 1)) ==
                    new ColorFloat(0, 0, 0));
                Assert.IsTrue((0 * new ColorFloat(-1, -1, -1)) ==
                    new ColorFloat(0, 0, 0));
                Assert.IsTrue((0 * new ColorFloat(2, 2, 2)) ==
                    new ColorFloat(0, 0, 0));
                Assert.IsTrue((0 * new ColorFloat(0, 0, 0)) ==
                    new ColorFloat(0, 0, 0));

                Assert.IsTrue((-1 * new ColorFloat(1, 1, 1)) ==
                    new ColorFloat(-1, -1, -1));
                Assert.IsTrue((-1 * new ColorFloat(-1, -1, -1)) ==
                    new ColorFloat(1, 1, 1));
                Assert.IsTrue((-1 * new ColorFloat(2, 2, 2)) ==
                    new ColorFloat(-2, -2, -2));
                Assert.IsTrue((-1 * new ColorFloat(0, 0, 0)) ==
                    new ColorFloat(0, 0, 0));

                Assert.IsTrue((0.5f * new ColorFloat(0.6f, 0.4f, 0.2f)) ==
                    new ColorFloat(0.3f, 0.2f, 0.1f));
                Assert.IsTrue((-0.5f * new ColorFloat(0.6f, 0.4f, 0.2f)) ==
                    new ColorFloat(-0.3f, -0.2f, -0.1f));
            }
        }

        public void ColorFloat_op_Multiply_ColorFloat()
        {
            Assert.IsTrue((new ColorFloat(1, 1, 1) * new ColorFloat(1, 1, 1)) == new ColorFloat(1, 1, 1));
            Assert.IsTrue((new ColorFloat(-1, -1, -1) * new ColorFloat(1, 1, 1)) == new ColorFloat(-1, -1, -1));
            Assert.IsTrue((new ColorFloat(2, 2, 2) * new ColorFloat(1, 1, 1)) == new ColorFloat(2, 2, 2));
            Assert.IsTrue((new ColorFloat(0, 0, 0) * new ColorFloat(1, 1, 1)) == new ColorFloat(0, 0, 0));

            Assert.IsTrue((new ColorFloat(1, 1, 1) * new ColorFloat(0, 0, 0)) == new ColorFloat(0, 0, 0));
            Assert.IsTrue((new ColorFloat(-1, -1, -1) * new ColorFloat(0, 0, 0)) == new ColorFloat(0, 0, 0));
            Assert.IsTrue((new ColorFloat(2, 2, 2) * new ColorFloat(0, 0, 0)) == new ColorFloat(0, 0, 0));
            Assert.IsTrue((new ColorFloat(0, 0, 0) * new ColorFloat(0, 0, 0)) == new ColorFloat(0, 0, 0));

            Assert.IsTrue((new ColorFloat(1, 1, 1) * new ColorFloat(-1, -1, -1)) == new ColorFloat(-1, -1, -1));
            Assert.IsTrue((new ColorFloat(-1, -1, -1) * new ColorFloat(-1, -1, -1)) == new ColorFloat(1, 1, 1));
            Assert.IsTrue((new ColorFloat(2, 2, 2) * new ColorFloat(-1, -1, -1)) == new ColorFloat(-2, -2, -2));
            Assert.IsTrue((new ColorFloat(0, 0, 0) * new ColorFloat(-1, -1, -1)) == new ColorFloat(0, 0, 0));

            Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) * new ColorFloat(0.5f, 0.5f, 0.5f)) == new ColorFloat(0.3f, 0.2f, 0.1f));
            Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) * new ColorFloat(-0.5f, -0.5f, -0.5f)) == new ColorFloat(-0.3f, -0.2f, -0.1f));

            Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) * new ColorFloat(0.5f, 1, 1)) == new ColorFloat(0.3f, 0.4f, 0.2f));
            Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) * new ColorFloat(1, 0.5f, 1)) == new ColorFloat(0.6f, 0.2f, 0.2f));
            Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) * new ColorFloat(1, 1, 0.5f)) == new ColorFloat(0.6f, 0.4f, 0.1f));
        }

        public void ColorFloat_op_Inequality()
        {
            Assert.IsFalse(new ColorFloat(0, 0, 0) != new ColorFloat(0, 0, 0));
            Assert.IsFalse(new ColorFloat(0.1f, 0.1f, 0.1f) != new ColorFloat(0.1f, 0.1f, 0.1f));
            Assert.IsFalse(new ColorFloat(1, 1, 1) != new ColorFloat(1, 1, 1));
            Assert.IsFalse(new ColorFloat(-1, -1, -1) != new ColorFloat(-1, -1, -1));
            Assert.IsFalse(new ColorFloat(2, 2, 2) != new ColorFloat(2, 2, 2));
            Assert.IsTrue(new ColorFloat(0.1f, 0, 0) != new ColorFloat(0, 0.1f, 0));
            Assert.IsTrue(new ColorFloat(0, 0, 0) != new ColorFloat(0, 0, 0.1f));
            Assert.IsTrue(new ColorFloat(0, 0.1f, 0) != new ColorFloat(0.1f, 0, 0));
            Assert.IsTrue(new ColorFloat(0, 0.1f, 0) != new ColorFloat(0, 0, 0.1f));
            Assert.IsTrue(new ColorFloat(0, 0, 0.1f) != new ColorFloat(0.1f, 0, 0));
            Assert.IsTrue(new ColorFloat(0, 0, 0.1f) != new ColorFloat(0, 0.1f, 0));
        }

        public void ColorFloat_op_Equality()
        {
            Assert.IsTrue(new ColorFloat(0, 0, 0) == new ColorFloat(0, 0, 0));
            Assert.IsTrue(new ColorFloat(0.1f, 0.1f, 0.1f) == new ColorFloat(0.1f, 0.1f, 0.1f));
            Assert.IsTrue(new ColorFloat(1, 1, 1) == new ColorFloat(1, 1, 1));
            Assert.IsTrue(new ColorFloat(-1, -1, -1) == new ColorFloat(-1, -1, -1));
            Assert.IsTrue(new ColorFloat(2, 2, 2) == new ColorFloat(2, 2, 2));

            Assert.IsFalse(new ColorFloat(0.1f, 0, 0) == new ColorFloat(0, 0.1f, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0) == new ColorFloat(0, 0, 0.1f));
            Assert.IsFalse(new ColorFloat(0, 0.1f, 0) == new ColorFloat(0.1f, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0.1f, 0) == new ColorFloat(0, 0, 0.1f));
            Assert.IsFalse(new ColorFloat(0, 0, 0.1f) == new ColorFloat(0.1f, 0, 0));
            Assert.IsFalse(new ColorFloat(0, 0, 0.1f) == new ColorFloat(0, 0.1f, 0));
        }

        public void ColorFloat_op_Division_ColorFloat()
        {
            Assert.IsTrue((new ColorFloat(1, 1, 1) / new ColorFloat(1, 1, 1)) == new ColorFloat(1, 1, 1));
            Assert.IsTrue((new ColorFloat(-1, -1, -1) / new ColorFloat(1, 1, 1)) == new ColorFloat(-1, -1, -1));
            Assert.IsTrue((new ColorFloat(2, 2, 2) / new ColorFloat(1, 1, 1)) == new ColorFloat(2, 2, 2));
            Assert.IsTrue((new ColorFloat(0, 0, 0) / new ColorFloat(1, 1, 1)) == new ColorFloat(0, 0, 0));

            Assert.IsTrue((new ColorFloat(1, 1, 1) / new ColorFloat(-1, -1, -1)) == new ColorFloat(-1, -1, -1));
            Assert.IsTrue((new ColorFloat(-1, -1, -1) / new ColorFloat(-1, -1, -1)) == new ColorFloat(1, 1, 1));
            Assert.IsTrue((new ColorFloat(2, 2, 2) / new ColorFloat(-1, -1, -1)) == new ColorFloat(-2, -2, -2));
            Assert.IsTrue((new ColorFloat(0, 0, 0) / new ColorFloat(-1, -1, -1)) == new ColorFloat(0, 0, 0));

            Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) / new ColorFloat(2, 2, 2)) == new ColorFloat(0.3f, 0.2f, 0.1f));
            Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) / new ColorFloat(-2, -2, -2)) == new ColorFloat(-0.3f, -0.2f, -0.1f));

            Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) / new ColorFloat(2, 1, 1)) == new ColorFloat(0.3f, 0.4f, 0.2f));
            Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) / new ColorFloat(1, 2, 1)) == new ColorFloat(0.6f, 0.2f, 0.2f));
            Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) / new ColorFloat(1, 1, 2)) == new ColorFloat(0.6f, 0.4f, 0.1f));
        }

        public void ColorFloat_op_Division_Single()
        {
            {
                Assert.IsTrue((new ColorFloat(1, 1, 1) / 1) ==
                    new ColorFloat(1, 1, 1));
                Assert.IsTrue((new ColorFloat(-1, -1, -1) / 1) ==
                    new ColorFloat(-1, -1, -1));
                Assert.IsTrue((new ColorFloat(2, 2, 2) / 1) ==
                    new ColorFloat(2, 2, 2));
                Assert.IsTrue((new ColorFloat(0, 0, 0) / 1) ==
                    new ColorFloat(0, 0, 0));

                Assert.IsTrue((new ColorFloat(1, 1, 1) / -1) ==
                    new ColorFloat(-1, -1, -1));
                Assert.IsTrue((new ColorFloat(-1, -1, -1) / -1) ==
                    new ColorFloat(1, 1, 1));
                Assert.IsTrue((new ColorFloat(2, 2, 2) / -1) ==
                    new ColorFloat(-2, -2, -2));
                Assert.IsTrue((new ColorFloat(0, 0, 0) / -1) ==
                    new ColorFloat(0, 0, 0));

                Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) / 2) ==
                    new ColorFloat(0.3f, 0.2f, 0.1f));
                Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) / -2) ==
                    new ColorFloat(-0.3f, -0.2f, -0.1f));
            }

            {
                Assert.IsTrue((1 / new ColorFloat(1, 1, 1)) == new ColorFloat(1, 1, 1));
                Assert.IsTrue((1 / new ColorFloat(-1, -1, -1)) == new ColorFloat(-1, -1, -1));
                Assert.IsTrue((1 / new ColorFloat(2, 2, 2)) == new ColorFloat(0.5f, 0.5f, 0.5f));

                Assert.IsTrue((-1 / new ColorFloat(1, 1, 1)) == new ColorFloat(-1, -1, -1));
                Assert.IsTrue((-1 / new ColorFloat(-1, -1, -1)) == new ColorFloat(1, 1, 1));
                Assert.IsTrue((-1 / new ColorFloat(2, 2, 2)) == new ColorFloat(-0.5f, -0.5f, -0.5f));

                Assert.IsTrue((0 / new ColorFloat(1, 1, 1)) == new ColorFloat(0, 0, 0));
                Assert.IsTrue((0 / new ColorFloat(-1, -1, -1)) == new ColorFloat(0, 0, 0));
                Assert.IsTrue((0 / new ColorFloat(2, 2, 2)) == new ColorFloat(0, 0, 0));

                Assert.IsTrue((2 / new ColorFloat(0.6f, 0.4f, 0.2f)) ==
                    new ColorFloat(2 / 0.6f, 2 / 0.4f, 2 / 0.2f));
                Assert.IsTrue((-2 / new ColorFloat(0.6f, 0.4f, 0.2f)) ==
                    new ColorFloat(-2 / 0.6f, -2 / 0.4f, -2 / 0.2f));
            }
        }

        public void ColorFloat_op_Addition()
        {
            Assert.IsTrue((new ColorFloat(1, 1, 1) + new ColorFloat(0, 0, 0)) == new ColorFloat(1, 1, 1));
            Assert.IsTrue((new ColorFloat(-1, -1, -1) + new ColorFloat(0, 0, 0)) == new ColorFloat(-1, -1, -1));
            Assert.IsTrue((new ColorFloat(2, 2, 2) + new ColorFloat(0, 0, 0)) == new ColorFloat(2, 2, 2));
            Assert.IsTrue((new ColorFloat(0, 0, 0) + new ColorFloat(0, 0, 0)) == new ColorFloat(0, 0, 0));

            Assert.IsTrue((new ColorFloat(1, 1, 1) + new ColorFloat(1, 1, 1)) == new ColorFloat(2, 2, 2));
            Assert.IsTrue((new ColorFloat(-1, -1, -1) + new ColorFloat(1, 1, 1)) == new ColorFloat(0, 0, 0));
            Assert.IsTrue((new ColorFloat(2, 2, 2) + new ColorFloat(1, 1, 1)) == new ColorFloat(3, 3, 3));
            Assert.IsTrue((new ColorFloat(0, 0, 0) + new ColorFloat(1, 1, 1)) == new ColorFloat(1, 1, 1));

            Assert.IsTrue((new ColorFloat(1, 1, 1) + new ColorFloat(-1, -1, -1)) == new ColorFloat(0, 0, 0));
            Assert.IsTrue((new ColorFloat(-1, -1, -1) + new ColorFloat(-1, -1, -1)) == new ColorFloat(-2, -2, -2));
            Assert.IsTrue((new ColorFloat(2, 2, 2) + new ColorFloat(-1, -1, -1)) == new ColorFloat(1, 1, 1));
            Assert.IsTrue((new ColorFloat(0, 0, 0) + new ColorFloat(-1, -1, -1)) == new ColorFloat(-1, -1, -1));

            Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) + new ColorFloat(1, 0, 0)) == new ColorFloat(1.6f, 0.4f, 0.2f));
            Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) + new ColorFloat(0, 1, 0)) == new ColorFloat(0.6f, 1.4f, 0.2f));
            Assert.IsTrue((new ColorFloat(0.6f, 0.4f, 0.2f) + new ColorFloat(0, 0, 1)) == new ColorFloat(0.6f, 0.4f, 1.2f));
        }

        public void ColorFloat_Constructor1()
        {
            ColorFloat c1 = new ColorFloat(0.1f);
            Assert.IsTrue(c1.R.IsAlmostRelativeEquals(0.1f));
            Assert.IsTrue(c1.G.IsAlmostRelativeEquals(0.1f));
            Assert.IsTrue(c1.B.IsAlmostRelativeEquals(0.1f));

            ColorFloat c2 = new ColorFloat(0f);
            Assert.IsTrue(c2.R.IsAlmostRelativeEquals(0.0f));
            Assert.IsTrue(c2.G.IsAlmostRelativeEquals(0.0f));
            Assert.IsTrue(c2.B.IsAlmostRelativeEquals(0.0f));

            ColorFloat c3 = new ColorFloat(-1f);
            Assert.IsTrue(c3.R.IsAlmostRelativeEquals(-1.0f));
            Assert.IsTrue(c3.G.IsAlmostRelativeEquals(-1.0f));
            Assert.IsTrue(c3.B.IsAlmostRelativeEquals(-1.0f));

            ColorFloat c4 = new ColorFloat(1f);
            Assert.IsTrue(c4.R.IsAlmostRelativeEquals(1.0f));
            Assert.IsTrue(c4.G.IsAlmostRelativeEquals(1.0f));
            Assert.IsTrue(c4.B.IsAlmostRelativeEquals(1.0f));

            ColorFloat c5 = new ColorFloat(2f);
            Assert.IsTrue(c5.R.IsAlmostRelativeEquals(2.0f));
            Assert.IsTrue(c5.G.IsAlmostRelativeEquals(2.0f));
            Assert.IsTrue(c5.B.IsAlmostRelativeEquals(2.0f));
        }

        public void ColorFloat_Constructor6()
        {
            ColorFloat c1 = new ColorFloat(0.1);
            Assert.IsTrue(c1.R.IsAlmostRelativeEquals(0.1f));
            Assert.IsTrue(c1.G.IsAlmostRelativeEquals(0.1f));
            Assert.IsTrue(c1.B.IsAlmostRelativeEquals(0.1f));

            ColorFloat c2 = new ColorFloat(0);
            Assert.IsTrue(c2.R.IsAlmostRelativeEquals(0.0f));
            Assert.IsTrue(c2.G.IsAlmostRelativeEquals(0.0f));
            Assert.IsTrue(c2.B.IsAlmostRelativeEquals(0.0f));

            ColorFloat c3 = new ColorFloat(-1);
            Assert.IsTrue(c3.R.IsAlmostRelativeEquals(-1.0f));
            Assert.IsTrue(c3.G.IsAlmostRelativeEquals(-1.0f));
            Assert.IsTrue(c3.B.IsAlmostRelativeEquals(-1.0f));

            ColorFloat c4 = new ColorFloat(1);
            Assert.IsTrue(c4.R.IsAlmostRelativeEquals(1.0f));
            Assert.IsTrue(c4.G.IsAlmostRelativeEquals(1.0f));
            Assert.IsTrue(c4.B.IsAlmostRelativeEquals(1.0f));

            ColorFloat c5 = new ColorFloat(2);
            Assert.IsTrue(c5.R.IsAlmostRelativeEquals(2.0f));
            Assert.IsTrue(c5.G.IsAlmostRelativeEquals(2.0f));
            Assert.IsTrue(c5.B.IsAlmostRelativeEquals(2.0f));
        }

        public void ColorFloat_Constructor2()
        {
            ColorFloat c1 = new ColorFloat(0.1f, 0.2f, 0.3f);
            Assert.IsTrue(c1.R.IsAlmostRelativeEquals(0.1f));
            Assert.IsTrue(c1.G.IsAlmostRelativeEquals(0.2f));
            Assert.IsTrue(c1.B.IsAlmostRelativeEquals(0.3f));

            ColorFloat c2 = new ColorFloat(0f, 0f, 0f);
            Assert.IsTrue(c2.R.IsAlmostRelativeEquals(0.0f));
            Assert.IsTrue(c2.G.IsAlmostRelativeEquals(0.0f));
            Assert.IsTrue(c2.B.IsAlmostRelativeEquals(0.0f));

            ColorFloat c3 = new ColorFloat(-1f, -1f, -1f);
            Assert.IsTrue(c3.R.IsAlmostRelativeEquals(-1.0f));
            Assert.IsTrue(c3.G.IsAlmostRelativeEquals(-1.0f));
            Assert.IsTrue(c3.B.IsAlmostRelativeEquals(-1.0f));

            ColorFloat c4 = new ColorFloat(1f, 1f, 1f);
            Assert.IsTrue(c4.R.IsAlmostRelativeEquals(1.0f));
            Assert.IsTrue(c4.G.IsAlmostRelativeEquals(1.0f));
            Assert.IsTrue(c4.B.IsAlmostRelativeEquals(1.0f));

            ColorFloat c5 = new ColorFloat(2f, 2f, 2f);
            Assert.IsTrue(c5.R.IsAlmostRelativeEquals(2.0f));
            Assert.IsTrue(c5.G.IsAlmostRelativeEquals(2.0f));
            Assert.IsTrue(c5.B.IsAlmostRelativeEquals(2.0f));
        }

        public void ColorFloat_Constructor5()
        {
            ColorFloat c1 = new ColorFloat(0.1, 0.2, 0.3);
            Assert.IsTrue(c1.R.IsAlmostRelativeEquals(0.1f));
            Assert.IsTrue(c1.G.IsAlmostRelativeEquals(0.2f));
            Assert.IsTrue(c1.B.IsAlmostRelativeEquals(0.3f));

            ColorFloat c2 = new ColorFloat(0, 0, 0);
            Assert.IsTrue(c2.R.IsAlmostRelativeEquals(0.0f));
            Assert.IsTrue(c2.G.IsAlmostRelativeEquals(0.0f));
            Assert.IsTrue(c2.B.IsAlmostRelativeEquals(0.0f));

            ColorFloat c3 = new ColorFloat(-1, -1, -1);
            Assert.IsTrue(c3.R.IsAlmostRelativeEquals(-1.0f));
            Assert.IsTrue(c3.G.IsAlmostRelativeEquals(-1.0f));
            Assert.IsTrue(c3.B.IsAlmostRelativeEquals(-1.0f));

            ColorFloat c4 = new ColorFloat(1, 1, 1);
            Assert.IsTrue(c4.R.IsAlmostRelativeEquals(1.0f));
            Assert.IsTrue(c4.G.IsAlmostRelativeEquals(1.0f));
            Assert.IsTrue(c4.B.IsAlmostRelativeEquals(1.0f));

            ColorFloat c5 = new ColorFloat(2, 2, 2);
            Assert.IsTrue(c5.R.IsAlmostRelativeEquals(2.0f));
            Assert.IsTrue(c5.G.IsAlmostRelativeEquals(2.0f));
            Assert.IsTrue(c5.B.IsAlmostRelativeEquals(2.0f));
        }

        public void ColorFloat_Constructor3()
        {
            ColorFloat c1 = new ColorFloat(Color.Red);
            Assert.IsTrue(c1.R.IsAlmostRelativeEquals(1.0f));
            Assert.IsTrue(c1.G.IsAlmostRelativeEquals(0.0f));
            Assert.IsTrue(c1.B.IsAlmostRelativeEquals(0.0f));

            ColorFloat c2 = new ColorFloat(Color.Blue);
            Assert.IsTrue(c2.R.IsAlmostRelativeEquals(0.0f));
            Assert.IsTrue(c2.G.IsAlmostRelativeEquals(0.0f));
            Assert.IsTrue(c2.B.IsAlmostRelativeEquals(1.0f));

            ColorFloat c3 = new ColorFloat(Color.Green);
            Assert.IsTrue(c3.R.IsAlmostRelativeEquals(0.0f));
            Assert.IsTrue(c3.G.IsAlmostRelativeEquals(128.0f / 255.0f));
            Assert.IsTrue(c3.B.IsAlmostRelativeEquals(0.0f));

            ColorFloat c4 = new ColorFloat(Color.FromArgb(1, 2, 3));
            Assert.IsTrue(c4.R.IsAlmostRelativeEquals(1.0f / 255.0f));
            Assert.IsTrue(c4.G.IsAlmostRelativeEquals(2.0f / 255.0f));
            Assert.IsTrue(c4.B.IsAlmostRelativeEquals(3.0f / 255.0f));
        }

        public void ColorFloat_Constructor4()
        {
            ColorFloat c1 = new ColorFloat(new ColorFloat(0.1f, 0.2f, 0.3f));
            Assert.IsTrue(c1.R.IsAlmostRelativeEquals(0.1f));
            Assert.IsTrue(c1.G.IsAlmostRelativeEquals(0.2f));
            Assert.IsTrue(c1.B.IsAlmostRelativeEquals(0.3f));

            ColorFloat c2 = new ColorFloat(new ColorFloat(0, 0, 0));
            Assert.IsTrue(c2.R.IsAlmostRelativeEquals(0.0f));
            Assert.IsTrue(c2.G.IsAlmostRelativeEquals(0.0f));
            Assert.IsTrue(c2.B.IsAlmostRelativeEquals(0.0f));

            ColorFloat c3 = new ColorFloat(new ColorFloat(-1, -1, -1));
            Assert.IsTrue(c3.R.IsAlmostRelativeEquals(-1.0f));
            Assert.IsTrue(c3.G.IsAlmostRelativeEquals(-1.0f));
            Assert.IsTrue(c3.B.IsAlmostRelativeEquals(-1.0f));

            ColorFloat c4 = new ColorFloat(new ColorFloat(1, 1, 1));
            Assert.IsTrue(c4.R.IsAlmostRelativeEquals(1.0f));
            Assert.IsTrue(c4.G.IsAlmostRelativeEquals(1.0f));
            Assert.IsTrue(c4.B.IsAlmostRelativeEquals(1.0f));

            ColorFloat c5 = new ColorFloat(new ColorFloat(2, 2, 2));
            Assert.IsTrue(c5.R.IsAlmostRelativeEquals(2.0f));
            Assert.IsTrue(c5.G.IsAlmostRelativeEquals(2.0f));
            Assert.IsTrue(c5.B.IsAlmostRelativeEquals(2.0f));
        }

        public void ColorFloat_Black()
        {
            Assert.IsTrue(new ColorFloat(0) == ColorFloat.Black);
            Assert.IsTrue(new ColorFloat(0, 0, 0) == ColorFloat.Black);

            Assert.IsFalse(new ColorFloat(0.1f) == ColorFloat.Black);
            Assert.IsFalse(new ColorFloat(-0.1f) == ColorFloat.Black);
            Assert.IsFalse(new ColorFloat(1.1f) == ColorFloat.Black);

            Assert.IsFalse(new ColorFloat(1, 0, 0) == ColorFloat.Black);
            Assert.IsFalse(new ColorFloat(0, 1, 0) == ColorFloat.Black);
            Assert.IsFalse(new ColorFloat(0, 0, 1) == ColorFloat.Black);
        }

        public void ColorFloat_op_UnaryMinus()
        {
            Assert.IsTrue((-new ColorFloat(-1, 2, 3)) == new ColorFloat(1, -2, -3));
            Assert.IsTrue((-new ColorFloat(1, -2, 3)) == new ColorFloat(-1, 2, -3));
            Assert.IsTrue((-new ColorFloat(1, 2, -3)) == new ColorFloat(-1, -2, 3));
            Assert.IsTrue((-new ColorFloat(0, 0, 0)) == new ColorFloat(0, 0, 0));
        }
    }
}